package cn.cboard.dao.sql;

import java.sql.ResultSet;
import java.sql.SQLException;

import cn.cboard.database.RowMapper;
import cn.cboard.model.ForumThread;
import cn.cboard.model.ForumTopic;

public class ThreadMapper implements RowMapper{
	
	public Object mapRow(ResultSet rs) throws SQLException {
		ForumThread forumThread = new ForumThread();
		
		forumThread.setForumId(rs.getLong("forumId"));
		forumThread.setThreadId(rs.getLong("threadId"));
		forumThread.setTitle(rs.getString("title"));
		forumThread.setCreationDate(rs.getDate("creationDate"));
		
		ForumTopic rootTopic = new ForumTopic();
		rootTopic.setTopicId(rs.getLong("rootTopicId"));
		
		forumThread.setRootTopic(rootTopic);
		
		return forumThread;
	}
}
